cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(sherpa-ncnn)

set(SHERPA_NCNN_VERSION_MAJOR "1")
set(SHERPA_NCNN_VERSION_MINOR "0")
set(SHERPA_NCNN_VERSION "${SHERPA_NCNN_VERSION_MAJOR}.${SHERPA_NCNN_VERSION_MINOR}")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(BUILD_RPATH_USE_ORIGIN TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

if(NOT APPLE)
  set(SHERPA_NCNN_RPATH_ORIGIN "$ORIGIN")
else()
  set(SHERPA_NCNN_RPATH_ORIGIN "@loader_path")
endif()

set(CMAKE_INSTALL_RPATH ${SHERPA_NCNN_RPATH_ORIGIN})
set(CMAKE_BUILD_RPATH ${SHERPA_NCNN_RPATH_ORIGIN})

option(BUILD_SHARED_LIBS "Whether to build shared libraries" OFF)
message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")

if(NOT CMAKE_BUILD_TYPE)
  message(STATUS "No CMAKE_BUILD_TYPE given, default to Release")
  set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.")
set(CMAKE_CXX_EXTENSIONS OFF)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ version to be used.")
set(CMAKE_CXX_EXTENSIONS OFF)

option(SHERPA_NCNN_ENABLE_PORTAUDIO "Whether to build with portaudio" ON)

include(kaldi-native-fbank)
include(ncnn)

if(SHERPA_NCNN_ENABLE_PORTAUDIO)
  include(portaudio)
endif()

add_subdirectory(sherpa-ncnn)
